﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
using System.Data;

namespace MidSoft.Message.SysMessage
{
    public partial class add : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindProjectInfo();
            }
        }
        private void BindProjectInfo()
        {
            ChinaSoft.BLL.Common.Bind bllBind = new ChinaSoft.BLL.Common.Bind();
            DataSet ds=bllBind.GetDataSet("ProjectInfoId,ProjectName", "tb_MidSoft_ProjectInfo", "");
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ChinaSoft.Common.BindControl.BindDropDownList(ddlProjectName, ds, "ProjectName", "ProjectInfoId");
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (ddlProjectName.SelectedValue!="")
            {
                strErr += "项目ID格式错误！\\n";
            }
            if (this.txtDescript.Text.Trim().Length == 0)
            {
                strErr += "描述不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int ProjectInfoId = ChinaSoft.Common.Input.SetInt(this.ddlProjectName.SelectedValue);
            string Descript = this.txtDescript.Text;
            DateTime CreateTime = DateTime.Now;
            int CreateUserId = 0;
            if (Session["currentUserID"] != null && Session["currentUserID"].ToString() != "")
                CreateUserId = ChinaSoft.Common.Input.SetInt(Session["currentUserID"]);
            string CreateUserName = "";
            if (Session["UserName"] != null && Session["UserName"].ToString() != "")
                CreateUserName = ChinaSoft.Common.Input.SetString(Session["UserName"]);
            ChinaSoft.Model.Model_tb_Midsoft_SysMessage model = new ChinaSoft.Model.Model_tb_Midsoft_SysMessage();
            model.ProjectInfoId = ProjectInfoId;
            model.Descript = Descript;
            model.CreateTime = CreateTime;
            model.CreateUserId = CreateUserId;
            model.CreateUserName = CreateUserName;

            ChinaSoft.BLL.BLL_tb_Midsoft_SysMessage bll = new ChinaSoft.BLL.BLL_tb_Midsoft_SysMessage();
            bll.Add(model);
            Response.Write("<script>alert('成功！');top.window.parent.frames.item('workspace').location.reload();window.parent.$('#DivSysiframe').dialog(\"close\");</script>");
        }

    }
}